<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <script src="../jQuery/jquery-1.11.2.js"></script>
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" href="../layui/css/modules/layui-icon-extend/iconfont.css" type="text/css"/>
    <style>::-webkit-scrollbar{display: none;}</style>
    <link rel="stylesheet" type="text/css" href="/css/font.css">
</head>
<body class="layui-layout-body">
<blockquote>


    <div id="data-main" style="display: none;">
        <div style="margin-left: 130px;margin-top: 20px">
            <form class="layui-form" id="adminiForm" method="post" lay-skin="line" lay-filter="adminiFormTest">
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="newPassword" lay-verify="required" style="width: 250px" placeholder="请输入新密码" autocomplete="off"
                               class="layui-input"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 250px;right: 170px;">重复新密码</label>
                    <div class="layui-input-inline" style="right: 170px;">
                        <input type="password" name="newPasswords" lay-verify="required"  style="width: 250px" placeholder="请重复输入新密码"
                               autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">旧密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="oldPassword" lay-verify="required" style="width: 250px"  placeholder="请输入旧密码" autocomplete="off"
                               class="layui-input"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn"  layui-bg-blue lay-submit lay-filter="formSave">确认</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="layui-layout layui-layout-admin" style="height: 100%;">
        <div class="layui-header" style="background: #B2B2B2">
            <div class="layui-logo" style="background: #393d49"><img src="../image/log6.gif"
                                                                           style="margin-top: 2px;width: 145px;height: 40px;margin-right: 100px;" id="logImage"/>
            </div>
            <!-- 头部区域（可配合layui已有的水平导航） -->
            <ul class="layui-nav layui-layout-left" id="handNav" style="background: #B2B2B2">
                <!--<li class="layui-nav-item"><a href="#" id="one">控制台</a></li>
                <li class="layui-nav-item"><a href="#" id="two">商品管理</a></li>
                <li class="layui-nav-item"><a href="#" id="three">用户</a></li>-->
            </ul>
            <ul class="layui-nav" style="float: right;right: 20px" >
                <li class="layui-nav-item">
                    <a href=""><!--<img src="../image/log.gif" class="layui-nav-img">--><i class='iconfont' style='font-size: 24px;'>&#xe74e;</i></a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="updatePassWord">修改密码</a></dd>
                        <dd><a href="javascript:;" id="exit">退了</a></dd>
                    </dl>
                </li>
            </ul>
        </div>

        <!--这是侧边导航栏标签-->
        <div class="layui-side layui-bg-black" id="navs" style="background: dodgerblue">
        </div>

        <!--主题内容区-->
        <div class="layui-body" style="height: 800px;overflow-y:hidden;overflow-x:hidden;">
            <iframe id="iframe" src="" style="width: 100%;height: 100%;overflow-y:hidden;overflow-x:hidden;"></iframe>
        </div>
    </div>
    <script>
        //JavaScript代码区域
        layui.use(['jquery', 'element','layer','table','form'], function () {
            var $ = layui.$;
            var element = layui.element;
            var form=layui.form;
            var arr = new Array();
            $.ajax({
                url: "/fc/sj",
                type: "get",
                async: false,
                success: function (data) {
                   father(data);
                }
            });
            var passwordOpen;
            //修改密码的点击按钮
            $("#updatePassWord").click(function () {
                passwordOpen=layer.open({
                    type: 1,//外部页面为2，内部层1
                    title: "<span style='color:white' align='center'><i class='layui-icon'>&#xe61f;</i>修改密码</span>",
                    area: ["40%", "40%"],
                    shade: 0.4,
                    anim: 1,
                    skin: 'layui-layer-lan',
                    content: $("#data-main").html()
                });
            });

            //判断点击的是修改密码
            form.on("submit(formSave)",function(data){
                var val=data.field;
                //判断输入的新密码和重复输入的新密码是否一致
                if (val.newPassword==val.newPasswords){
                    //将数据发送到服务器端
                    $.ajax({
                        type:"put",
                        url:"../uc/method/"+val.newPassword+"/"+val.oldPassword,
                        data:"",
                        success:function(data){
                            if (data==1){
                                layer.msg("修改成功");
                                layer.close(passwordOpen);
                            }else if (data==2){
                                layer.msg("修改失败");
                            }else{
                                layer.msg("密码错误");
                            }
                        }
                    });
                    return false;
                }else{
                    layer.msg("您输入的新密码和重复新密码不一致")
                    return  false;
                }
            });

            //点击了退出
            $("#exit").click(function () {
                //绑定监听事件
                top.location.href="Login.html";
                layer.msg('退出成功', {icon: 1});
                /*layer.confirm('您确认退出登陆吗?', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    top.location.href="Login.html";
                    layer.msg('退出成功', {icon: 1});
                }, function(){
                    layer.msg('你已取消', {
                        time: 2000, //20s后自动关闭
                    });
                });*/
            });

            function father(data) {
                var fstr = "";
                var str = "";
                var fid;
                $.each(data, function (index, item) {
                    if (item.funparentId == "root_menu") {
                        fid = item.funId;
                        str = "";
                        fstr = fstr + "<li class=\"layui-nav-item\"><a href=\"#\" id=\"" + item.funId + "\" style='color:white;background: #B2B2B2'><i class='iconfont' style='font-size: 14px;'>"+item.icon+"&nbsp" + item.funName + "</a></li>"
                        if(item.funtype!="son"){
                            str = str + "<div class=\"layui-side-scroll\" >" +
                                "<ul class=\"layui-nav layui-nav-tree\" lay-filter=\"test\">";
                            $.each(data,function (a,e) {
                                if(item.funId==e.funparentId){
                                    str = str + "<li class=\"layui-nav-item\">" +
                                        "<a class='"+e.funUrl+"' href=\"javascript:;\" id='"+e.funId+"' ><i class='iconfont' style='font-size: 14px;'>"+e.icon+"&nbsp" + e.funName + "</i></a>";
                                    if(e.funtype =="dad"){
                                        str = str + "<dl class='layui-nav-child'>";
                                        $.each(data,function (j,k) {
                                            if(e.funId==k.funparentId){
                                                str = str + "<dd><a href=\"javascript:;\" id='" + k.funId + "' class='" + k.funUrl + "'><i class='iconfont' style='font-size: 14px;'>"+k.icon+"&nbsp" + k.funName + "</a></dd>";
                                            }
                                        });
                                        str = str + "</dl>";
                                    }
                                    str = str + "</li>";
                                }

                            });

                        }

                        str = str + "</ul>" +
                            "</div>";
                        arr.push(fid + "%^" + str);
                    }
                });
                $("#handNav").append(fstr);
                $("#navs").append(arr[0].split("%^")[1]);
                element.init();
                f();
            }
            var first;
            var two;
            function f(){
                $("#navs  a").each(function (a,e) {
                    //点击第一个模块
                    if ($(this).attr("id")=="f11"){
                        first=$(this);
                    }
                    $(this).click(function () {
                        if($(this).attr("class")!="null"){
                            $("#iframe").attr("src", $(this).attr("class"));
                        }
                    });

                });
            };
            $("#handNav a").each(function (a,e) {
                //自动点击第一个模块
                if ($(this).attr("id")=="f2s"){
                    two=$(this);
                    two.click();
                }
              $(this).click(function () {
                  if($(this).attr("id")=="fsy"){
                      $("#iframe").attr("src", $(this).attr("class"));
                  }else{
                      for (var i=0;i<arr.length;i++){
                          if($(this).attr("id")==arr[i].split("%^")[0]){
                              $("#navs").empty();
                              $("#navs").html(arr[i].split("%^")[1]);
                              element.init();
                              f();
                          }
                      }
                  }
              });
            })
            //启动页面自动点击首页
            first.click();
            //点击log是自动点击首页
            $("#logImage").click(function(){
                two.click();
                first.click();
            });
        });
    </script>
</blockquote>
</body>
</html>